{{ $preUrl := relURL "/" }}

{{- if hugo.IsProduction -}}
    <script src="{{ $preUrl }}static/vendor/bootstrap/dist/js/bootstrap.bundle.min.js"></script>
{{- else -}}
    <script src="{{ $preUrl }}static/vendor/bootstrap/dist/js/bootstrap.bundle.js"></script>
{{- end }}

<script src="{{ $preUrl }}static/vendor/axios/dist/axios.min.js"></script>
<script src="{{ $preUrl }}static/vendor/wretch/dist/bundle/wretch.min.js"></script>
<script src="{{ $preUrl }}static/vendor/js-cookie/dist/js.cookie.min.js"></script>
<script src="{{ $preUrl }}static/vendor/vanilla-cookieconsent/dist/cookieconsent.umd.js"></script>

{{ if eq .IsHome false }}
{{ if and (ne .Page.Params.navbar "hide") (ne .Page.Params.onlyMain true) }}
<script src="{{ $preUrl }}static/vendor/@docsearch/js/dist/umd/index.js"></script>
<script src="{{ $preUrl }}static/js/doc-search.js"></script>
{{ end }}
{{ end }}

{{- if hugo.IsProduction -}}
<script async src="{{ $preUrl }}static/js/busuanzi.pure.min.js"></script>
{{ end }}

<script src="{{ $preUrl }}static/vendor/localforage/dist/localforage.min.js"></script>
<script src="{{ $preUrl }}static/vendor/workbox-sw/build/workbox-sw.js"></script>
<script src="{{ $preUrl }}static/vendor/lozad/dist/lozad.min.js"></script>
<script src="{{ $preUrl }}static/vendor/dayjs/dayjs.min.js"></script>
<script src="{{ $preUrl }}static/vendor/qrcode/build/qrcode.js"></script>
<script src="{{ $preUrl }}static/vendor/clipboard/dist/clipboard.min.js"></script>
<script src="{{ $preUrl }}static/vendor/@zumer/snapdom/dist/snapdom.min.js"></script>
<script src="{{ $preUrl }}static/vendor/@glidejs/glide/dist/glide.min.js"></script>
<script src="{{ $preUrl }}static/vendor/timeago.js/dist/timeago.min.js"></script>
<script src="{{ $preUrl }}static/vendor/b-components-js/dist/b.bundle.min.js"></script>

{{ if in .Page.Params.components "sortablejs" }}
    <script type="module" src="{{ $preUrl }}static/vendor/sortablejs/modular/sortable.esm.js"></script>
{{ end }}

{{ if in .Page.Params.components "interactjs" }}
    <script src="{{ $preUrl }}static/vendor/interactjs/dist/interact.min.js"></script>
{{ end }}

{{ if in .Page.Params.components "handsontable" }}
    <script src="{{ $preUrl }}static/vendor/handsontable/dist/handsontable.full.min.js"></script>
    <script src="{{ $preUrl }}static/vendor/handsontable/dist/languages/zh-CN.min.js"></script>
    <script src="{{ $preUrl }}static/js/handsontable.js"></script>
{{ end }}

{{ if in .Page.Params.components "handsontable-simple" }}
    <script src="{{ $preUrl }}static/vendor/handsontable/dist/handsontable.min.js"></script>
    <script src="{{ $preUrl }}static/vendor/handsontable/dist/languages/zh-CN.min.js"></script>
    <script src="{{ $preUrl }}static/js/handsontable.js"></script>
{{ end }}

{{ if in .Page.Params.components "datatables" }}
    <script src="{{ $preUrl }}static/vendor/simple-datatables/dist/umd/simple-datatables.js"></script>
    <script src="{{ $preUrl }}static/js/sDataTables.js"></script>
{{ end }}

{{ if in .Page.Params.components "photoswipe" }}
    <script type="module" src="{{ $preUrl }}static/js/photoswipe.js"></script>
{{ end }}

{{ if in .Page.Params.components "medium-zoom" }}
    <script type="module" src="{{ $preUrl }}static/js/medium-zoom.js"></script>
{{ end }}

{{ if in .Page.Params.components "svgedit" }}
    <script src="{{ $preUrl }}static/vendor/svgedit/dist/editor/iife-Editor.js"></script>
    <script src="{{ $preUrl }}static/js/svgedit.js"></script>
{{ end }}

{{ if in .Page.Params.components "uppy" }}
    <script src="{{ $preUrl }}static/vendor/uppy/dist/uppy.min.js"></script>
    <script src="{{ $preUrl }}static/vendor/@uppy/locales/dist/zh_CN.min.js"></script>
    <script src="{{ $preUrl }}static/js/uppy.js"></script>
{{ end }}

{{ if in .Page.Params.components "randomColor" }}
    <script src="{{ $preUrl }}static/vendor/randomcolor/randomColor.js"></script>
{{ end }}

{{ if in .Page.Params.components "lunar" }}
    <script src="{{ $preUrl }}static/vendor/lunar-javascript/lunar.js"></script>
    {{- $lunarJS := partial "functions/script/build" (dict "resourcesGet" "static/js/lunar.js" "targetPath" "static/js/lunar.js") }}
    <script src="{{ $lunarJS }}"></script>
{{ end }}

{{ if in .Page.Params.components "calendar" }}
    <script src="{{ $preUrl }}static/vendor/jcalendar.js/dist/calendar.min.js"></script>
    <script src="{{ $preUrl }}static/vendor/jcalendar.js/dist/translations/calendar.translations.zh.js"></script>
{{ end }}

{{ if in .Page.Params.components "sign_record" }}
    {{- $fullcalendarJS := partial "functions/script/build" (dict "resourcesGet" "static/js/sign_record.js" "targetPath" "static/js/sign_record.js") }}
    <script src="{{ $fullcalendarJS }}"></script>
{{ end }}

{{ if in .Page.Params.components "calendar" }}
    {{- $calendarJS := partial "functions/script/build" (dict "resourcesGet" "static/js/calendar.js" "targetPath" "static/js/calendar.js") }}
    <script src="{{ $calendarJS }}"></script>
{{ end }}


{{ if and hugo.IsProduction (.Site.Params.DisableDevtool.enable) }}
<script src="{{ $preUrl }}static/vendor/disable-devtool/disable-devtool.min.js"></script>
{{ end }}

{{- $commonJs := partial "functions/concat" (dict "concatPath" "static/js/common/**.js" "targetPath" "static/js/common.bundle.js") }}
<script src="{{ $commonJs }}"></script>

{{- $accountJs := partial "functions/concat" (dict "concatPath" "static/js/account/**.js" "targetPath" "static/js/account.bundle.js") }}
<script src="{{ $accountJs }}"></script>

{{- $postJs := partial "functions/script/build" (dict "resourcesGet" "static/js/post.js" "targetPath" "static/js/post.js") }}
<script src="{{ $postJs }}"></script>

{{- $bulletinJs := partial "functions/script/build" (dict "resourcesGet" "static/js/bulletin.js" "targetPath" "static/js/bulletin.js") }}
<script src="{{ $bulletinJs }}"></script>

{{- if eq .Page.Layout "jump_link" -}}
    {{- $jump_linkJs := partial "functions/script/build" (dict "resourcesGet" "static/js/jump_link.js" "targetPath" "static/js/jump_link.js") }}
    <script src="{{ $jump_linkJs }}"></script>
{{- end -}}


{{- $tagsJs := partial "functions/script/build" (dict "resourcesGet" "static/js/publish/tags.js" "targetPath" "static/js/publish/tags.js") }}
{{- $writeJs := partial "functions/script/build" (dict "resourcesGet" "static/js/publish/write.js" "targetPath" "static/js/publish/write.js") }}

{{ if eq .Type "publish" -}}
    <script src="{{ $writeJs }}"></script>
    <script src="{{ $tagsJs }}"></script>
{{ end }}

{{ if eq .Type "publish" -}}
    <script src="{{ $preUrl }}static/vendor/vditor/dist/index.min.js"></script>
    <script src="{{ $preUrl }}static/js/vditor/edit.js"></script>
{{ end -}}

{{ if and (eq .Type "posts") (eq .Kind "page") -}}
    <script src="{{ $preUrl }}static/vendor/vditor/dist/method.min.js"></script>
    <script src="{{ $preUrl }}static/js/vditor/render.js"></script>
{{ end -}}

{{ if eq .Type "contact" -}}
    {{- $contactJs := partial "functions/script/build" (dict "resourcesGet" "static/js/contact.js" "targetPath" "static/js/contact.js") }}
    <script src="{{ $contactJs }}"></script>
{{ end -}}

{{ if eq .Type "shop" -}}
    {{- $shopJs := partial "functions/script/build" (dict "resourcesGet" "static/js/shop/index.js" "targetPath" "static/js/shop/index.js") }}
    <script src="{{ $shopJs }}"></script>
{{ end -}}


{{ if eq .Type "shop/list" -}}
    {{- $shop_listJs := partial "functions/script/build" (dict "resourcesGet" "static/js/shop/list.js" "targetPath" "static/js/shop/list.js") }}
    <script src="{{ $shop_listJs }}"></script>
{{ end -}}

{{ if eq .Type "shop/add" -}}
    {{- $shop_addJs := partial "functions/script/build" (dict "resourcesGet" "static/js/shop/add.js" "targetPath" "static/js/shop/add.js") }}
    <script src="{{ $shop_addJs }}"></script>
{{ end -}}

{{ if eq .Type "shop/info" -}}
    {{- $shop_infoJs := partial "functions/script/build" (dict "resourcesGet" "static/js/shop/info.js" "targetPath" "static/js/shop/info.js") }}
    <script src="{{ $shop_infoJs }}"></script>
{{ end -}}

{{- if eq .Page.Layout "full_page" -}}
    <script src="{{ $preUrl }}static/vendor/randomcolor/randomColor.js"></script>
    <script src="{{ $preUrl }}static/js/full_page.js"></script>
{{- end -}}

{{ if hasPrefix .Type "aqxc" }}
    <script src="{{ $preUrl }}static/js/aqxc/common.js"></script>
{{ end }}

{{ if hasPrefix .Type "zhgh" }}
    <script src="{{ $preUrl }}static/js/zhgh/common.js"></script>
{{ end }}

{{ if eq .Type "zhgh" }}
    <script src="{{ $preUrl }}static/js/zhgh/index.js"></script>
{{ end }}

{{ if eq .Type "zhgh/passwork" }}
    <script src="{{ $preUrl }}static/js/zhgh/passwork.js"></script>
{{ end }}

{{ if eq .Type "zhgh/study" }}
    <script src="{{ $preUrl }}static/js/zhgh/study.js"></script>
{{ end }}

{{ if eq .Type "zhgh/list" }}
    <script src="{{ $preUrl }}static/js/zhgh/list.js"></script>
{{ end }}

{{ if hasPrefix .Type "aqxc/quiz/" }}
    <script src="{{ $preUrl }}static/js/aqxc/tester_category.js"></script>
    <script src="{{ $preUrl }}static/js/aqxc/quiz/quiz.js"></script>
{{ end }}

{{ if hasPrefix .Type "aqxc/study" }}
    <script src="{{ $preUrl }}static/js/aqxc/study/category.js"></script>
{{ end }}

{{ if eq .Type "aqxc" }}
    <script src="{{ $preUrl }}static/js/aqxc/index.js"></script>
    <script src="{{ $preUrl }}static/js/aqxc/sign_in.js"></script>
{{ end }}

{{ if eq .Type "aqxc/study" }}
    <script src="{{ $preUrl }}static/js/aqxc/study/study.js"></script>
{{ end }}

{{ if eq .Type "aqxc/study/batch" }}
    <script src="{{ $preUrl }}static/js/aqxc/study/batch.js"></script>
{{ end }}

{{ if eq .Type "aqxc/quiz/exercise" }}
    <script src="{{ $preUrl }}static/js/aqxc/quiz/exercise.js"></script>
{{ end }}

{{ if eq .Type "aqxc/quiz/single" }}
    <script src="{{ $preUrl }}static/js/aqxc/quiz/single.js"></script>
{{ end }}

{{ if eq .Type "aqxc/quiz/pk/invite" }}
    <script src="{{ $preUrl }}static/js/aqxc/quiz/pkInvite.js"></script>
{{ end }}

{{ if eq .Type "aqxc/quiz/pk/random" }}
    <script src="{{ $preUrl }}static/js/aqxc/quiz/pkRandom.js"></script>
{{ end }}

{{ if eq .Type "aqxc/quiz/multi" }}
    <script src="{{ $preUrl }}static/js/aqxc/quiz/multi.js"></script>
{{ end }}

{{ if eq .Type "aqxc/quiz/award_valid" }}
    <script src="{{ $preUrl }}static/js/aqxc/quiz/awardValid.js"></script>
{{ end }}

{{ if eq .Type "aqxc/read/article" }}
    <script src="{{ $preUrl }}static/js/aqxc/read/article.js"></script>
{{ end }}

{{ if eq .Type "aqxc/top/quiz" }}
    <script src="{{ $preUrl }}static/js/aqxc/top/quiz.js"></script>
{{ end }}

{{ if eq .Type "aqxc/top/study" }}
    <script src="{{ $preUrl }}static/js/aqxc/top/study.js"></script>
{{ end }}

{{ if hasPrefix .Type "aqxc/top/" }}
    <script src="{{ $preUrl }}static/js/aqxc/top/top.js"></script>
{{ end }}

{{ if eq .Type "aqxc/questions" }}
    <script src="{{ $preUrl }}static/js/aqxc/tester_category.js"></script>
    <script src="{{ $preUrl }}static/js/aqxc/questions/index.js"></script>
{{ end }}

{{ if eq .Type "aqxc/favourite" }}
    <script src="{{ $preUrl }}static/js/aqxc/favourite/index.js"></script>
{{ end }}

{{ if eq .Type "aqxc/stat/study" }}
    <script src="{{ $preUrl }}static/js/aqxc/stat/study.js"></script>
{{ end }}

{{ if eq .Type "aqxc/stat/quiz" }}
    <script src="{{ $preUrl }}static/js/aqxc/stat/quiz.js"></script>
{{ end }}

{{ if eq .Type "aqxc/records/study" }}
    <script src="{{ $preUrl }}static/js/aqxc/records/study.js"></script>
{{ end }}

{{ if eq .Type "aqxc/records/quiz" }}
    <script src="{{ $preUrl }}static/js/aqxc/records/quiz.js"></script>
{{ end }}
